php remove last character in string

75

php remove last character from string if comma -

$string = rtrim($string, ',');

Remove the Last Character From a String in PHP -

phpCopy<?php
$mystring = "This is a PHP program.";
echo substr($mystring, 0, -1);
?>

php string remove last character -

echo substr('a,b,c,d,e,', 0, -1);
# => 'a,b,c,d,e'

Comments

Submit
0 Comments